package com.itheima.sys.controller;

import com.itheima.common.vo.Result;
import com.itheima.sys.dto.SysRoleDTO;
import com.itheima.sys.dto.SysRoleEditDTO;
import com.itheima.sys.entity.SysRole;
import com.itheima.sys.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SysRoleController {

    @Autowired
    private ISysRoleService roleService;

    /**
     * 查询当前企业包含角色列表
     * @return
     */
    @GetMapping("/company/role")
    public Result<List<SysRoleDTO>> queryRolesByCompanyId(){
        return Result.success(roleService.queryRolesByCompanyId());
    }

    /**
     * 编辑角色
     * @param sysRoleEditDTO
     * @return
     */
    @PutMapping("/company/role")
    public Result updateRole(@RequestBody SysRoleEditDTO sysRoleEditDTO){
        roleService.updateRole(sysRoleEditDTO);
        return Result.success();
    }
}
